home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-25 | 57.4 KB | 1,494 lines |
- -----------------------------------------------------------------------
- T U R B O S T U F F v 0 2 . 0 1 . 0 0
- -----------------------------------------------------------------------
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- \\///////////////////////////////////////////////////////////////////\\
- \\///////////////// // // // // // ////////////\\
- \\////////////////// //// // // // // // // // /////////////\\
- \\///////////////// //// // // // /// // //////////////\\
- \\//////////////// //// // // / /// // // // ///////////////\\
- \\/////////////// //// // // // // ////////////////\\
- \\///////////////////////////////////////////////////////////////////\\
- \\///////////////////////////////////////////////////////////////////\\
- \\///////////////// // // // // // ////////////\\
- \\//////////////// //////// //// // // ////// /////////////////\\
- \\/////////////// //// //// // // /// ///////////////\\
- \\////////////////// //// //// // // ////// ///////////////////\\
- \\///////////// //// //// // ////// ////////////////////\\
- \\///////////////////////////////////////////////////////////////////\\
- \\///////////////////////////////////////////////////////////////////\\
- \\//////////// // ////////// // // /////////\\
- \\///////////// //// ////////////// //////// //// // //////////\\
- \\//////////// //// ////////// //// //// ///////////\\
- \\/////////// //////// ////////////// //// //// / /////////////\\
- \\////////// //// // // //// //// // /////////////\\
- \\///////////////////////////////////////////////////////////////////\\
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
-
- TS_STR Module Reference
-
-
-
-
-
-
-
-
-
-
-
-
- Shenandoah Valley Software
- P.O. Box 1456
- Winchester, Va 22601
- 703-665-6491
-
- -----------------------------------------------------------------------
- (C) Copyright 1989 by Shenandoah Valley Software -- All Rights Reserved
- -----------------------------------------------------------------------
-
- TS_Str TURBO STUFF REFERENCE Page: 1
- _______________________________________________________________________
-
-
- T A B L E O F C O N T E N T S
- TS_STR Reference
-
-
- For information on how to use the Turbo Stuff Toolbox, please refer to
- the TS_STR.DOC file included in the archive.
-
-
- Ascii .......................................................... 2
- AsciiZ ......................................................... 3
- ATrim .......................................................... 4
- Center ......................................................... 5
- Change ......................................................... 6
- Compare ........................................................ 7
- DelCh .......................................................... 8
- Decrypt ........................................................ 9
- Dup ............................................................ 10
- DupStr ......................................................... 11
- Encrypt ........................................................ 12
- FirstLower ..................................................... 13
- FirstUpper ..................................................... 14
- Format ......................................................... 15
- IIf ............................................................ 16
- IsAlpha ........................................................ 17
- IsLower ........................................................ 18
- IsUpper ........................................................ 19
- LFill .......................................................... 20
- Left ........................................................... 21
- LJust .......................................................... 22
- LoCase ......................................................... 23
- Lower .......................................................... 24
- LTrim .......................................................... 25
- Number ......................................................... 26
- Proper ......................................................... 27
- RFill .......................................................... 28
- Right .......................................................... 29
- RJust .......................................................... 30
- Roman .......................................................... 31
- RTrim .......................................................... 32
- Same ........................................................... 33
- SoundDif ....................................................... 34
- SoundEx ........................................................ 35
- Space .......................................................... 36
- Stuff .......................................................... 37
- Swap ........................................................... 38
- Trim ........................................................... 39
- Upper .......................................................... 40
- Words .......................................................... 41
-
- TS_Str TURBO STUFF REFERENCE Page: 2
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ASCII function
- -----------------------------------------------------------------------
-
- Function The ASCII function returns a string previously converted
- to Asciiz back to its original format.
-
- Declaration Ascii ( St:string )
-
- Result Type String
-
- Remarks The first byte of a Turbo Pascal string, position [0],
- holds the actual length of the string. However, many DOS
- services require Asciiz string. The first byte of this
- string type actually holds the first character of the
- string, while the last byte contains a Null (ASCII 0)
- byte.
-
- The function is passed but one parameter, (St), which
- contains the Asciiz string to be converted.
-
- See Also AsciiZ
-
- Source File ASCII
-
- TS_Str TURBO STUFF REFERENCE Page: 3
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ASCIIZ function
- -----------------------------------------------------------------------
-
- Function The ASCIIZ function converts a standard Turbo Pascal
- string into a zero, or null, terminated string.
-
- Declaration AsciiZ ( St:string )
-
- Result Type String
-
- Remarks The first byte of a Turbo Pascal string, position [0],
- holds the actual length of the string. However, many DOS
- services require Asciiz string. The first byte of this
- string type actually holds the first character of the
- string, while the last byte contains a Null (ASCII 0)
- byte.
-
- The function is passed but one parameter, (St), which
- contains the string to be converted.
-
- Writing Asciiz string may have unpredictable results.
- Turbo assumes a string to be printed with Write or
- Writeln to have the length contained in the first byte.
- Since Asciiz string have the first character of the
- string in this byte, the result may be a string that is
- too short, or may contain garbage characters following
- it. In any case, this function is primarily designed to
- be used with the various DOS services though the MsDos
- procedure (Turbo Pascal Reference Guide, page 334).
-
- See Also Ascii
-
- Source File ASCII
-
- TS_Str TURBO STUFF REFERENCE Page: 4
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ATRIM function
- -----------------------------------------------------------------------
-
- Function This function will return a string with a specific char-
- acter removed from the beginning and end of a string.
-
- Declaration ATrim ( St:string; Ch:char )
-
- Result Type String
-
- Remarks This function is passed two parameters. The first, (St),
- contains the string that is to be trimmed. The second,
- (Ch), contains the character that is to be removed.
-
- See Also LTrim, RTrim, Trim
-
- Source File ATRIM
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := '***** THIS IS A TEST *****';
- WRITELN ( '>', ATRIM(ST,'*'), '<' );
- END.
-
-
- This produces the following result:
-
- > THIS IS A TEST <
-
- TS_Str TURBO STUFF REFERENCE Page: 5
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- CENTER function
- -----------------------------------------------------------------------
-
- Function The CENTER function will return a string centered within
- a specified field length.
-
- Declaration Center ( St:string; Ch:char; Len:byte )
-
- Result Type String
-
- Remarks The first of three parameters required by this function
- is (St), which contains the string to be centered. The
- second parameter, (Ch), is the character used to pad the
- beginning and end of the string within the field. The
- last, (Len), is the actual length of the field.
-
- See Also LJust, RJust
-
- Source File CENTER
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := ' THIS IS A TEST ';
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( CENTER(ST,'*',30 );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- ******* THIS IS A TEST *******
-
- TS_Str TURBO STUFF REFERENCE Page: 6
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- CHANGE function
- -----------------------------------------------------------------------
-
- Function The function CHANGE, replace all occurances of a char-
- acter with another character.
-
- Declaration Change ( St:string; Search,Replace:char )
-
- Result Type String
-
- Remarks This function will search the entire string passed,
- (St), for the character specified in (Search). Upon a
- match, the character will be replaced with the one found
- in (Replace).
-
- See Also DelCh
-
- Source File CHANGE
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := '***** THIS * IS * A * TEST *****';
- WRITELN ( CHANGE(ST,'*','-') );
- END.
-
-
- This produces the following result:
-
- ----- THIS - IS - A - TEST -----
-
- TS_Str TURBO STUFF REFERENCE Page: 7
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- COMPARE function
- -----------------------------------------------------------------------
-
- Function This function will compare two strings and return TRUE
- is they are the same.
-
- Declaration Compare ( St1,St2:string; UCase:boolean )
-
- Result Type Boolean
-
- Remarks This function can be either case sensitive, or insensi-
- tive depending on the status of the parameter (UCase).
- If true, COMPARE will automatically convert the string
- to uppercase before testing.
-
- Obviously, the other two parameters, (St1) and (St2),
- are the string to be compared.
-
- See Also Same
-
- Source File COMPARE
-
- Example VAR ST1,ST2:STRING;
-
- BEGIN
- ST1 := 'THIS IS A TEST';
- ST2 := 'this is a test';
- WRITELN ( COMPARE(ST1,ST2,TRUE) );
- WRITELN ( COMPARE(ST1,ST2,FALSE) );
- END.
-
-
- This produces the following result:
-
- true
- false
-
- TS_Str TURBO STUFF REFERENCE Page: 8
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- DELCH function
- -----------------------------------------------------------------------
-
- Function The function DELCH, removes every occurance of the char-
- acter specified from a string.
-
- Declaration DelCh ( St:string; Ch:char )
-
- Result Type String
-
- Remarks DelCh will remove every character found within the
- string passed, (St), that matches the character in (Ch).
-
- See Also Change
-
- Source File DELCH
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := '***** THIS * IS * A * TEST *****';
- WRITELN ( DELCH(ST,'*') );
- END.
-
-
- This produces the following result:
-
- THIS IS A TEST
-
- TS_Str TURBO STUFF REFERENCE Page: 9
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- DECRYPT function
- -----------------------------------------------------------------------
-
- Function This function decrypts a string that had be previously
- encrypted with the ENCRYPT function.
-
- Declaration Decrypt ( St:string )
-
- Result Type String
-
- Remarks The only parameter of this function is the string that
- had been previous encrypted.
-
- See Also Encrypt
-
- Source File DECRYPT
-
- TS_Str TURBO STUFF REFERENCE Page: 10
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- DUP function
- -----------------------------------------------------------------------
-
- Function This function DUPlicates a character a specific number
- of times and returns the result as a string.
-
- Declaration Dup ( Ch:char; Num:byte )
-
- Result Type String
-
- Remarks The character passed in (Ch) is duplicated (Num) times
- before being returned.
-
- See Also DupStr, Space
-
- Source File DUP
-
- Example BEGIN
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( DUP('*',30) );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- ******************************
-
- TS_Str TURBO STUFF REFERENCE Page: 11
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- DUPSTR function
- -----------------------------------------------------------------------
-
- Function This function is very similar to the DUP function except
- that is duplicates a string for a specific length.
-
- Declaration DupStr ( St:string; Len:byte )
-
- Result Type String
-
- Remarks The string passed as (St) will be duplicated up to a
- maximum length as specified in (Len). If the length of
- the string is so long as to make the final length longer
- than (Len), the string will be truncated to (Len).
-
- See Also Dup
-
- Source File DUPSTR
-
- Example BEGIN
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( DUPSTR('<**>',30) );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- <**><**><**><**><**><**><**><**><**><**
-
- TS_Str TURBO STUFF REFERENCE Page: 12
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ENCRYPT function
- -----------------------------------------------------------------------
-
- Function The function ENCRYPT will encrypt a string so that in
- will be unreadable.
-
- Declaration Encrypt ( St:string )
-
- Result Type String
-
- Remarks This single parameter is obviously the string to be
- encrypted.
-
- The encryption scheme is a relatively simple, but
- effective, one. Each character, except the last, is
- XORed with the next character in the string. The result
- is then shifted left by one. The last character is
- unaffected and is used as the starting point for the
- DECRYPT function.
-
- See Also Decrypt
-
- Source File DECRYPT
-
- TS_Str TURBO STUFF REFERENCE Page: 13
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- FIRSTLOWER function
- -----------------------------------------------------------------------
-
- Function This function will return the first lowercase character
- located within a string.
-
- Declaration FirstLower ( St:string )
-
- Result Type String
-
- Remarks This only parameter is the string to be searched.
-
- See Also FirstUpper
-
- Source File FLOWER
-
- Example Is one really required?
-
- TS_Str TURBO STUFF REFERENCE Page: 14
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- FIRSTUPPER function
- -----------------------------------------------------------------------
-
- Function This function will return the first uppercase character
- located within a string.
-
- Declaration FirstUpper ( St:string )
-
- Result Type String
-
- Remarks This only parameter is the string to be searched.
-
- See Also FirstLower
-
- Source File FUPPER
-
- Example Is one really required?
-
- TS_Str TURBO STUFF REFERENCE Page: 15
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- FORMAT function
- -----------------------------------------------------------------------
-
- Function FORMAT is a simple string formatting procedure using a
- mask as defined by the user.
-
- Declaration Format ( St,Mask:string )
-
- Result Type String
-
- Remarks The string passed, (St), will be formatted as specified
- in the (Mask) parameter. Any character matching one of
- those listed below will be interpreted as described. Any
- character NOT matching one below will be inserted into
- the string. Any character that is not valid for the mask
- specified will be replaced with a blank space.
-
- MASK RESULT
- ---- --------------------------------------------
- * Anything above ASCII 31 [32..255]
-
- # Number only, ['0'..'9']
-
- ? Letters only, ['A'..'Z','a'..'z']
-
- & As ?, with all lowercase characters being
- converted to uppercase
-
- ! As *, with all lowercase characters being
- converted to uppercase
-
- See Also Number
-
- Source File FORMAT
-
- Example BEGIN
- WRITELN( FORMAT('18005551212','#-###-###-####') );
- WRITELN( FORMAT('123456789','###-##-####') );
- END.
-
-
- This produces the following result:
-
- 1-800-555-1212
- 123-45-6789
-
- TS_Str TURBO STUFF REFERENCE Page: 16
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- IIF function
- -----------------------------------------------------------------------
-
- Function This function stands for "Immediate If", and is meant as
- a short-cut replacement to the standard IF..THEN..ELSE
- process.
-
- Declaration IIF ( TF:boolean; St1,St2:string )
-
- Result Type String
-
- Remarks Depending on the condition passed as (TF), the function
- will return (St1) if the condition is true or (St2) if
- false.
-
- Source File IIF
-
- Example VAR SEX :CHAR;
- LNAME:STRING;
-
- BEGIN
- WRITE('ENTER YOUR LAST NAME: ');
- READLN(LNAME);
- WRITE('ENTER YOUR SEX: (M)ALE (F)EMALE: ');
- READLN(SEX);
- WRITELN;
- WRITELN ( IIF((SEX='M'),'MR. ','MS. '), LNAME );
- END.
-
-
- This produces the following result: (items in <> are
- user responses)
-
- ENTER YOUR LAST NAME: <COULTER>
- ENTER YOUR SEX: (M)ALE (F)EMALE: <M>
-
- MR. COULTER
-
-
- Note: if the sex would have been entered as <F>, the
- condition passed (SEX='M') would have been false, and
- thus the second string would have been returned instead.
-
- TS_Str TURBO STUFF REFERENCE Page: 17
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ISALPHA function
- -----------------------------------------------------------------------
-
- Function This function will return TRUE is the character (or
- string) passed contains only ABCs.
-
- Declaration IsAplha ( St:string )
-
- Result Type Boolean
-
- Remarks The string passed will be evaluated for contents of only
- ['A'..'Z','a'..'z']. Any other character, including
- spaces, will cause the function to return false.
-
- Note: This function is primarily intended to be used
- with single character but was designed to accept string
- for greater flexibility.
-
- See Also IsLower, IsUpper
-
- Source File ISALPHA
-
- TS_Str TURBO STUFF REFERENCE Page: 18
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ISLOWER function
- -----------------------------------------------------------------------
-
- Function This function will return TRUE is the character (or
- string) passed contains only lowercase ABCs.
-
- Declaration IsLower ( St:string )
-
- Result Type Boolean
-
- Remarks The string passed will be evaluated for contents of only
- ['a'..'z']. Any other character, including spaces, will
- cause the function to return false.
-
- Note: This function is primarily intended to be used
- with single character but was designed to accept string
- for greater flexibility.
-
- See Also IsAlpha, IsUpper
-
- Source File ISLOWER
-
- TS_Str TURBO STUFF REFERENCE Page: 19
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ISUPPER function
- -----------------------------------------------------------------------
-
- Function This function will return TRUE is the character (or
- string) passed contains only uppercase ABCs.
-
- Declaration IsUpper ( St:string )
-
- Result Type Boolean
-
- Remarks The string passed will be evaluated for contents of only
- ['A'..'Z']. Any other character, including spaces, will
- cause the function to return false.
-
- Note: This function is primarily intended to be used
- with single character but was designed to accept string
- for greater flexibility.
-
- See Also IsAlpha, IsLower
-
- Source File ISUPPER
-
- TS_Str TURBO STUFF REFERENCE Page: 20
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- LFILL function
- -----------------------------------------------------------------------
-
- Function This function will fill the left side of a string with a
- character specified up to a maximum length.
-
- Declaration LFill ( St:string; Ch:char; Len:byte )
-
- Result Type String
-
- Remarks The first of three parameters required by this function
- is (St), which contains the string to be filled. The
- second parameter, (Ch), is the character used to pad the
- beginning of the string within the field. The last,
- (Len), is the actual length of the field.
-
- See Also RFill
-
- Source File LFILL
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := ' THIS IS A TEST';
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( LFILL(ST,'*',30) );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- ************************ THIS IS A TEST
-
- TS_Str TURBO STUFF REFERENCE Page: 21
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- LEFT function
- -----------------------------------------------------------------------
-
- Function The function LEFT will return only the leftmost portion
- of a string.
-
- Declaration Left ( St:string; Len:byte )
-
- Result Type String
-
- Remarks This function will returns a number of characters as
- specified in (Len) from the left of the string (St).
-
- See Also Right
-
- Source File LEFT
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'THIS IS A TEST';
- WRITELN ( LEFT(ST,7) );
- END.
-
-
- This will produce the following result:
-
- THIS IS
-
- TS_Str TURBO STUFF REFERENCE Page: 22
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- LJUST function
- -----------------------------------------------------------------------
-
- Function LJUST will left justify a string within a field of
- spaces.
-
- Declaration LJust ( St:string; Len:byte )
-
- Result Type String
-
- Remarks The string (St) will have trailing spaces added to
- justify it within the field lenght of (Len).
-
- See Also RJust
-
- Source File LJUST
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'THIS IS A TEST';
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( LJUST(ST,30), '<--' );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- THIS IS A TEST <--
-
- TS_Str TURBO STUFF REFERENCE Page: 23
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- LOCASE function
- -----------------------------------------------------------------------
-
- Function This function is similar to the standard function UPCASE
- as included with Turbo Pascal, but convert the character
- to lowercase.
-
- Declaration LoCase ( Ch:char ) : char;
-
- Result Type Char
-
- Remarks This function has only one parameter, (Ch), which is the
- character to be converted.
-
- See Also Lower, Upper
-
- Source File LOCASE
-
- TS_Str TURBO STUFF REFERENCE Page: 24
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- LOWER function
- -----------------------------------------------------------------------
-
- Function This function converts all uppercase characters within a
- string to lowercase.
-
- Declaration Lower ( St:string )
-
- Result Type String
-
- Remarks This single parameter (St) is the string to be converted
- to lowercase.
-
- See Also LoCase, Proper, Upper
-
- Source File LOWER
-
- TS_Str TURBO STUFF REFERENCE Page: 25
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- LTRIM function
- -----------------------------------------------------------------------
-
- Function This function will return a string with a specific char-
- acter removed from the beginning of a string.
-
- Declaration LTrim ( St:string; Ch:char )
-
- Result Type String
-
- Remarks This function is passed two parameters. The first, (St),
- contains the string that is to be trimmed. The second,
- (Ch), contains the character that is to be removed.
-
- See Also ATrim, RTrim, Trim
-
- Source File LTRIM
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := '***** THIS IS A TEST *****';
- WRITELN ( '>', ATRIM(ST,'*'), '<' );
- END.
-
-
- This produces the following result:
-
- > THIS IS A TEST *****<
-
- TS_Str TURBO STUFF REFERENCE Page: 26
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- NUMBER function
- -----------------------------------------------------------------------
-
- Function The function NUMBER will format a number (in string
- format) to a string with commas.
-
- Declaration Number ( St:string; Decimals:byte )
-
- Result Type String
-
- Remarks The number passed must be a string. Use the standard
- Turbo Pascal function STR to convert number types to a
- string.
-
- The number passed is done so in (St). The number of
- digits to be included to the right of the decimal point
- is passed in (Decimals).
-
- This function has special error checking facilities
- built in. Before any conversion is done, it stips all
- non-numeric character from the string.
-
- See Also Format
-
- Source File NUMBER
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := '1234567890.12345';
- WRITELN ( NUMBER(ST,3):17 );
- ST := 'ASDF123456789LKJH';
- WRITELN ( NUMBER(ST,3):17 );
- ST := '111,222,333.444';
- WRITELN ( NUMBER(ST,3):17 );
- END.
-
-
- This produces the following result:
-
- 1,234,567,890.123
- 123,456,789.000
- 111,222,333.444
-
- TS_Str TURBO STUFF REFERENCE Page: 27
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- PROPER function
- -----------------------------------------------------------------------
-
- Function This function will return a string with the first letter
- of each word converted to uppercase while all others are
- converted to lowercase.
-
- Declaration Proper ( St:string )
-
- Result Type String
-
- Remarks The only parameters is the string (St) to be converted.
-
- See Also Lower, Upper
-
- Source File PROPER
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'JONATHAN W. COULTER';
- WRITELN ( PROPER(ST) );
- END.
-
-
- This produces the following result:
-
- Jonathan W. Coulter
-
- TS_Str TURBO STUFF REFERENCE Page: 28
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- RFILL function
- -----------------------------------------------------------------------
-
- Function This function will fill the right side of a string with
- a character specified up to a maximum length.
-
- Declaration RFill ( St:string; Ch:char; Len:byte )
-
- Result Type String
-
- Remarks The first of three parameters required by this function
- is (St), which contains the string to be filled. The
- second parameter, (Ch), is the character used to pad the
- end of the string within the field. The last, (Len), is
- the actual length of the field.
-
- See Also LFill
-
- Source File RFILL
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'THIS IS A TEST ';
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( RFILL(ST,'*',30) );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- THIS IS A TEST ************************
-
- TS_Str TURBO STUFF REFERENCE Page: 29
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- RIGHT function
- -----------------------------------------------------------------------
-
- Function The function RIGHT will return the rightmost portion of
- a string.
-
- Declaration Right ( St:string; Len:byte )
-
- Result Type String
-
- Remarks This function will returns a number of characters as
- specified in (Len) from the right of the string (St).
-
- See Also Left
-
- Source File RIGHT
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'THIS IS A TEST';
- WRITELN ( RIGHT(ST,7) );
- END.
-
-
- This will produce the following result:
-
- A TEST
-
- TS_Str TURBO STUFF REFERENCE Page: 30
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- RJUST function
- -----------------------------------------------------------------------
-
- Function RJUST will right justify a string within a field of
- spaces.
-
- Declaration RJust ( St:string; Len:byte )
-
- Result Type String
-
- Remarks The string (St) will have leading spaces added to
- justify it within the field length of (Len).
-
- See Also LJust
-
- Source File RJUST
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'THIS IS A TEST';
- WRITELN ( '---------1---------2---------3---------' );
- WRITELN ( RJUST(ST,30) );
- END.
-
-
- This produces the following result:
-
- ---------1---------2---------3---------
- THIS IS A TEST
-
- TS_Str TURBO STUFF REFERENCE Page: 31
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- ROMAN function
- -----------------------------------------------------------------------
-
- Function The function ROMAN will convert any number, up to 3999,
- to its equivalant Roman Numerial.
-
- Declaration Roman ( Num:integer )
-
- Result Type String
-
- Remarks The single parameter (Num) is the number to be converted
- to a roman numerial.
-
- Note: the reason numbers above 3999 are not supported is
- the fact that the PC can not duplicate those symbols in
- normal text mode.
-
- Restrictions Number greater than 3999 are not permitted.
-
- Source File ROMAN
-
- Example VAR I:INTEGER;
-
- BEGIN
- FOR I := 1 to 10 DO WRITELN ( ROMAN(I):4 );
- END.
-
-
- This produces the following result:
-
- I
- II
- III
- IV
- V
- VI
- VII
- VIII
- IX
- X
-
- TS_Str TURBO STUFF REFERENCE Page: 32
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- RTRIM function
- -----------------------------------------------------------------------
-
- Function This function will return a string with a specific char-
- acter removed from the end of a string.
-
- Declaration RTrim ( St:string; Ch:char )
-
- Result Type String
-
- Remarks This function is passed two parameters. The first, (St),
- contains the string that is to be trimmed. The second,
- (Ch), contains the character that is to be removed.
-
- See Also ATrim, LTrim, Trim
-
- Source File RTRIM
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := '***** THIS IS A TEST *****';
- WRITELN ( '>', RTRIM(ST,'*'), '<' );
- END.
-
-
- This produces the following result:
-
- >***** THIS IS A TEST <
-
- TS_Str TURBO STUFF REFERENCE Page: 33
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- SAME function
- -----------------------------------------------------------------------
-
- Function The function SAME will compare two strings and return
- whether or not the string match. Wildcards are allowed
- in the second string.
-
- Declaration Same ( St1,St2:string )
-
- Result Type Boolean
-
- Remarks Although very similar to the COMPARE function, this
- function does not alter the case before the comparision.
- However, this function does have one luxury that the
- former does not. The second string passed can contain
- any of the standard DOS wildcards.
-
- Upon encountering a '?' in the second string, it
- corresponding character in the first string is ignored.
- If an '*' is encountered, the function automatically
- returns TRUE, providing that all characters up to the
- '*' have matched.
-
- See Also Compare
-
- Source File SAME
-
- Example BEGIN
- WRITELN ( SAME('THIS IS A TEST','this is a test') );
- WRITELN ( SAME('THIS IS A TEST','THIS IS*a test') );
- WRITELN ( SAME('THIS IS A TEST','THIS IS ? TEST') );
- END.
-
-
- This produces the following result:
-
- false
- true
- true
-
- TS_Str TURBO STUFF REFERENCE Page: 34
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- SOUNDDIF function
- -----------------------------------------------------------------------
-
- Function This functions returns a difference code computed from
- two Soundex codes.
-
- Declaration SoundDif ( St1,St2:string )
-
- Result Type Byte
-
- Remarks The two paramters passed must be four digit soundex
- codes. If either string is not, the result will be 4.
-
- The main advantage of this function is used in database
- searches or spell checking. If a incorrect entry is
- made, all those with a SoundDif of 0 would be displayed
- to choose from. If none were found, or if a broader list
- is desired, those with a SoundDif of 1 could be
- displayed.
-
- See Also SoundEx
-
- Source File SOUNDDIF
-
- Example VAR ST1,ST2,ST3:STRING;
-
- BEGIN
- ST1 := 'COULTER';
- ST2 := 'COLTER';
- ST3 := 'KOULTER';
- WRITELN ( SOUNDDIF(ST1,ST2) );
- WRITELN ( SOUNDDIF(ST1,ST3) );
- END.
-
-
- This produces the following result:
-
- 0
- 1
-
- TS_Str TURBO STUFF REFERENCE Page: 35
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- SOUNDEX function
- -----------------------------------------------------------------------
-
- Function The SOUNDEX function returns a phonetic match, or sound-
- alike code, to facilitate finding a matching when the
- exact spelling is not known.
-
- Declaration SoundEx ( St:string )
-
- Result Type String
-
- Remarks The SOUNDEX function returns a four-character code by
- using the following algorithm:
-
- 1) It retains the first character of the string (St)
-
- 2) It drops all occurrences of the letters: A E H I O U
- W and Y in all position except the first.
-
- 3) All lower case letters are automatically converted to
- uppercase.
-
- 4) It assigns a number to the remaining letters as shown
- in the below table:
-
- B F P V = 1
- C H J K Q S X Z = 2
- D T = 3
- L = 4
- M N = 5
- R = 6
-
- 5) If two or more adjacent letters have the same code,
- it ignores all but the first letter found.
-
- 6) It stops at the first occurance of a non-alpha char-
- acter.
-
- 7) It returns a code in the form of A000.
-
- 8) It skips over leading blanks
-
- 9) It returns '0000' if the first non-blank character is
- not an alpha.
-
- See Also SoundDif
-
- Source File SOUNDDEX
-
- Example See the demonstration program for an example.
-
- TS_Str TURBO STUFF REFERENCE Page: 36
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- SPACE function
- -----------------------------------------------------------------------
-
- Function This function returns a string of blank spaces.
-
- Declaration Space ( Len:byte )
-
- Result Type String
-
- Remarks The only parameter required is the length (Len) of the
- string.
-
- See Also Dup
-
- Source File SPACE
-
- Example BEGIN
- WRITELN ( '->', SPACE(30), '<-' );
- END.
-
-
- This produces the following result:
-
- -> <-
-
- TS_Str TURBO STUFF REFERENCE Page: 37
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- STUFF function
- -----------------------------------------------------------------------
-
- Function The function STUFF changes any part of a string without
- the need to reconstruct the entire string.
-
- Declaration Stuff ( St1,St2:string; Start,Del:byte )
-
- Result Type String
-
- Remarks The parameter (St1) is the original string that is to be
- altered while (St2) is the string to be inserted. The
- start position is passed as (Start) and indicates where
- you want to begin the replacemet. Note that (St2) is
- inserted BEFORE the position defined by (Start). The
- (Del) parameter indicates how many characters you want
- to remove from the original string.
-
- If (Del) is zero, (St2) is simply inserted into (St1)
- and no characters are removed.
-
- If (Start) is zero, or is greater than the length of the
- original string (St1), then (St2) will be tagged to the
- end of the original and (Del) will be ignored.
-
- If (St2) is passed as a null string (i.e. '') then the
- number of characters specified in (Del) will be removed.
-
- Source File STUFF
-
- Example BEGIN
- WRITELN ( STUFF('ABC','XYZ',2,1) );
- WRITELN ( STUFF('ABC','',2,1) );
- WRITELN ( STUFF('ABC','XYZ',2,0) );
- WRITELN ( STUFF('ABC','XYZ',0,0) );
- END.
-
-
- This produces the following result:
-
- AXYZC
- AC
- AXYZBC
- ABCXYZ
-
- TS_Str TURBO STUFF REFERENCE Page: 38
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- SWAP procedure
- -----------------------------------------------------------------------
-
- Function The SWAP function simply swaps the contents of two
- strings.
-
- Declaration Swap ( var St1,St2:string )
-
- Result Type none
-
- Remarks Swap will return the value of (St1) in (St2) and vice-
- versa. Note that the actual length of the string does
- not matter.
-
- Source File SWAP
-
- Example VAR ST1,ST2:string;
-
- BEGIN
- ST1 := 'THIS IS TEST STRING #1';
- ST2 := 'THIS IS TEST #2';
- WRITELN('BEFORE #1: ',ST1);
- WRITELN(' #2: ',ST2);
- SWAP(ST1,ST2);
- WRITELN;
- WRITELN('AFTER #1: ',ST1);
- WRITELN(' #2: ',ST2);
- END.
-
-
- This produces the following result:
-
- BEFORE #1: THIS IS TEST STRING #1
- #2: THIS IS TEST #2
-
- AFTER #1: THIS IS TEST #2
- #2: THIS IS TEST STRING #1
-
- TS_Str TURBO STUFF REFERENCE Page: 39
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- TRIM function
- -----------------------------------------------------------------------
-
- Function This function will return a string with all leading and
- trailing spaces removed from a string.
-
- Declaration Trim ( St:string )
-
- Result Type String
-
- Remarks The only parameter passed is (St), which is the string
- to be trimmed.
-
- See Also ATrim, LTrim, RTrim
-
- Source File TRIM
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := ' THIS IS A TEST ';
- WRITELN ( '>', TRIM(ST), '<' );
- END.
-
-
- This produces the following result:
-
- >THIS IS A TEST<
-
- TS_Str TURBO STUFF REFERENCE Page: 40
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- UPPER function
- -----------------------------------------------------------------------
-
- Function This function converts all lowercase characters within a
- string to uppercase.
-
- Declaration Upper ( St:string )
-
- Result Type String
-
- Remarks This single parameter (St) is the string to be converted
- to uppercase.
-
- See Also LoCase, Lower, Proper
-
- Source File UPPER
-
- TS_Str TURBO STUFF REFERENCE Page: 41
- _______________________________________________________________________
-
- -----------------------------------------------------------------------
- WORDS function
- -----------------------------------------------------------------------
-
- Function The function WORDS returns the number of words contained
- within a string.
-
- Declaration Words ( St:string )
-
- Result Type Integer
-
- Remarks The lone parameter is the string to be counted.
-
- Source File WORDS
-
- Example VAR ST:STRING;
-
- BEGIN
- ST := 'THIS IS TURBO STUFF! YEAAAAH!';
- WRITELN ( 'THE NUMBER OF WORDS IS: ', WORDS(ST) );
- END.
-
-
- This produces the following result:
-
- THE NUMBER OF WORDS IS: 5
-
-